package ocl;

import metamodels.Identifier;
import metamodels.Type;

public class VariableDeclaration extends OclExpression{

	
	
	private SimpleName name;
	private Type type;
	private OclExpression exp;
	private Identifier id;

	public VariableDeclaration(SimpleName simpleName) {
		this(simpleName, null, null);
	}

	public VariableDeclaration(SimpleName simpleName, Type type) {
		this(simpleName, type, null);
	}

	public VariableDeclaration(SimpleName simpleName,
			OclExpression oclExpression) {
		this(simpleName, null, oclExpression);
	}

	public VariableDeclaration(SimpleName simpleName, Type type,
			OclExpression oclExpression) {
		this.name = simpleName;
		this.type = type;
		this.exp = oclExpression;
	}

	public VariableDeclaration(Identifier data) {
		this.id = data;
	}

	@Override
	public String toK() {
		if (id != null)
			return id.toString();
		
		String out = "";
		
		if (name != null)
			out += name.toK();
		
		if (type != null)
			out += " : " + type.toString();

		if (exp != null)
			out += " = " + exp.toK();
		
		return out;
	}
}
